home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
LIBRARY
/
DMTDEMOS
/
GETFIRST.DEM
< prev
next >
Wrap
Text File
|
1994-07-02
|
3KB
|
126 lines
program GetFirstSample;
uses crt, DMT;
var
FileInfoBuffer : FileInfoStruct; { The FileInfoStruct data type is defined in the DMT unit }
FileSpec : string;
Fname : string[ 12 ];
Attributes,
Count : byte;
Hr,
Min,
Sec,
Month,
Day,
Year : word;
MatchFlag : boolean;
procedure DecodeDate( Date : word;
var
Month,
Day,
Year : word );
begin
Month := ( Date and $1E0 ) shr 5;
Day := Date and $1F;
Year := ( Date shr 9 ) + 1980;
end;
procedure DecodeTime( Time : word;
var
Hr,
Min,
Sec : word );
begin
Hr := Time shr 11;
Min := ( Time and $7E0 ) shr 5;
Sec := ( Time and $1f ) * 2;
end;
begin
Fname := '';
Color( 7, 0 );
clrscr;
SetDTA( seg( FileInfoBuffer ), ofs( FileInfoBuffer ) ); { Call SetDTA procedure }
writeln;
write('Enter file to be searched : ');
readln( FileSpec );
if ( FileSpec = '' ) then
FileSpec := '*.*';
Attributes := 255; { Sets all available attributes }
GetFirst( FileSpec, Attributes ); { Call GetFirst procedure }
if ( ErrFlag ) then
begin
writeln( #7 );
writeln( ShowError( GetErrCode ) );
end
else
with FileInfoBuffer do
begin
clrscr;
writeln;
Count := 1;
while ( FileNameExt[ Count ] <> #0 ) do
begin
Fname := Fname + FileNameExt[ Count ];
inc( Count );
end;
writeln( 'Name : ', Fname :-12 );
writeln( 'Size in bytes : ', InsComma( FileSize ):-12 );
DecodeTime( FileTime, Hr, Min, Sec );
writeln( 'Last update time : ', Hr, ':', Min, ':', Sec );
DecodeDate( FileDate, Month, Day, Year );
writeln( 'Last update date : ', Month, '/', Day, '/', Year );
write ( 'Attributes : ' );
if ( FileAttrib and $20 ) = $20 then
write( 'Archive ' ); { Backup required }
if ( FileAttrib and $10 ) = $10 then
write( 'Subdirectory ' );
if ( FileAttrib and $02 ) = $02 then
write( 'Hidden ' );
if ( FileAttrib and $01 ) = $01 then
write( 'Read-Only ' );
if ( FileAttrib and $04 ) = $04 then
write( 'System ' );
if ( FileAttrib and $08 ) = $08 then
write( 'Volume-Label ' );
if ( FileAttrib = $00 ) then
write( 'Normal ' );
writeln;
end;
GetEnter;
end.